
require '界面.属性面板.攻击按钮'
require '界面.属性面板.护甲按钮'
require '界面.属性面板.三维按钮'
require '界面.属性面板.经验按钮'

local console = require '系统.基础界面.控制台'

local info = {}
local unitdetail = console.unitdetail:add_panel('',0,0)
local herodetail = console.herodetail:add_panel('',0,0)


unitdetail.title = unitdetail:add_text('名字',(1920 - 450)/2,875,450,20,13,5)
unitdetail.tip = unitdetail:add_text('',(1920 - 400)/2,900,400,200,13,8)

info['攻击按钮'] = unitdetail:add_attack_button('',753,933,74,56)
info['护甲按钮'] = unitdetail:add_armor_button('',753,991,74,56)

info['三维按钮'] = herodetail:add_attrs_button('',979,960,74,56)
info['经验按钮'] = herodetail:add_exp_button('',753,900,430,30)



local function update(unit)
    local unit = unit or ac.unit.localunit()
    if not unit then
        return
    end
    unitdetail.title:set_text(unit.ui_name or unit.name)
    if unit.shop_tip then
        unitdetail.tip:set_text(unit.shop_tip)
        unitdetail.tip:show()
        for key,button in pairs(info) do
            button:hide()
        end
        return
    else
        unitdetail.tip:hide()
    end
    for key,button in pairs(info) do
        button:show()
        button:notify('update',unit)
    end
    
end

ac.game:notify('游戏-注册三维文本',info['三维按钮'])

ac.console:event "控制台-刷新" (function ()
    update()
end)

ac.message:event '选择单位' (function(_, handle)
    local unit = ac.unit(handle)
    update(unit)
end)


return info